package com.jeestudio.gateway.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeestudio.common.beans.ResponseResult;
import com.jeestudio.gateway.common.beans.params.TestBean;
import com.jeestudio.gateway.services.ITestService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by shuttle on 2019/8/6.
 */
@RestController
@RequestMapping("/jeestudio")
@Log
public class TestController extends BaseController {

    @Autowired
    ITestService testService;

    @ApiOperation(value = "测试")
    @RequestMapping(value = "/getAdOfMain", method = RequestMethod.POST)
    public ResponseResult test() {
        try {
            System.out.print("aaa");
            ResponseResult responseResult = testService.test();
            return responseResult;
        } catch (Exception e) {
            log.info("获取开屏广告->" + ExceptionUtils.getStackTrace(e));
            return failed();
        }
    }


    @ApiOperation(value = "json")
    @RequestMapping(value = "/jsonConvert", method = RequestMethod.POST)
    public ResponseResult jsonConvert() {
        try {
            TestBean bean = new TestBean();
            bean.setAge("1");
            bean.setName("zs");
            bean.setTal("1.86m");
            ResponseResult<TestBean> responseResult = new ResponseResult();
            responseResult.setCode(1);
            responseResult.setMsg("成功");
            responseResult.setData(bean);
            responseResult.setExt(JSON.toJSONString(bean));
            return responseResult;
        } catch (Exception e) {
            log.info("获取开屏广告->" + ExceptionUtils.getStackTrace(e));

            return failed();
        }
    }
}
